﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Collection.DbEntities;
using Collection.Entities;

namespace Collection.Interfaces
{
	public interface ICatalogService : IServiceBase<Catalog>
	{
		#region 根属性事件相关

		/// <summary>
		/// 根属性插入数据库时发生该事件
		/// </summary>
		event Action<Property> InsertPropertyToDatabase;

		/// <summary>
		/// 根属性更新至数据库时引发该事件
		/// </summary>
		event Action<Property> UpdatePropertyToDatabase;

		#endregion

		#region 属性值事件相关

		/// <summary>
		/// 属性值插入时发生
		/// </summary>
		event Action<PropertyValue> InsertPropertyValueToDatabase;

		/// <summary>
		/// 属性值更新时插入时发生
		/// </summary>
		event Action<PropertyValue> UpdatePropertyValueToDataBase;

		#endregion

		#region 类目相关

		/// <summary>
		/// 获取所有的类目信息
		/// </summary>
		/// <returns>所有的类目信息</returns>
		IList<Catalog> GetCatalogs();

		/// <summary>
		///依据类目Id 获取单个分类对象
		/// </summary>
		/// <param name="catalogId">类目Id</param>
		/// <returns>单个类目对象</returns>
		Catalog GetCatalogById(long catalogId);

		#endregion

		#region 类目根属性相关

		/// <summary>
		/// 添加类目根属性数据
		/// </summary>
		/// <param name="property">根属性对象</param>
		void AddProperty(Property property);

		/// <summary>
		/// 更新类目根属性数据
		/// </summary>
		/// <param name="property">根属性对象</param>
		void UpdateProperty(Property property);

		/// <summary>
		/// 获取一个类目的所有根属性信息
		/// </summary>
		/// <param name="catalogId">类目Id</param>
		/// <returns>该类目相关的所有根属性</returns>
		IList<Property> GetPropertiesByCatalog(Int64 catalogId);

		/// <summary>
		/// 获取所有的属性信息
		/// </summary>
		/// <returns>属性信息</returns>
		List<Property> GetProperties();

		/// <summary>
		/// 获取商品属性信息
		/// </summary>
		/// <param name="catalog">类目Id</param>
		/// <param name="Id">淘宝的属性Id</param>
		/// <returns></returns>
		Property GetProperty(Int64 catalog, Int64 Id);

		/// <summary>
		/// 指定类目指定的根属性数据是否已经存在
		/// </summary>
		/// <param name="catalogId">类目Id</param>
		/// <param name="propertyId">根属性Id</param>
		/// <returns>存在：true;不存在：false</returns>
		Boolean HasProperty(Int64 catalogId, Int64 propertyId);


		#endregion

		#region 属性值相关

		/// <summary>
		/// 添加属性值数据
		/// <param name="propertyValue">属性值对象</param>
		/// </summary>
		void AddPropertyValue(PropertyValue propertyValue);

		/// <summary>
		/// 更新属性值
		/// </summary>
		/// <param name="propertyValue">属性值</param>
		void UpdatePropertyValue(PropertyValue propertyValue);

		/// <summary>
		/// 检测指定的属性值是否存在
		/// </summary>
		/// <param name="propertyValue">属性值对象</param>
		/// <returns>True:存在,False:不存在</returns>
		Boolean HasPropertyValue(PropertyValue propertyValue);

		/// <summary>
		/// 获取属性值信息
		/// </summary>
		/// <param name="catalog">类目</param>
		/// <param name="property">属性</param>
		/// <param name="propertyValue">属性值</param>
		/// <returns>指定的属性值信息（唯一）</returns>
		PropertyValue GetPropertyValue(Int64 catalog, Int64 propertyId, Int64 propertyValueId);

		/// <summary>
		/// 索取指定分类指定属性的所有属性值信息
		/// </summary>
		/// <param name="catalogId">指定的类目Id</param>
		/// <param name="propertyId">指定的属性Id</param>
		/// <returns>指定分类指定属性的所有属性值信息</returns>
		List<PropertyValue> GetPropertyValues(Int64 catalogId, Int64 propertyId);

		/// <summary>
		/// 获取一个指定属性值的子属性值
		/// </summary>
		/// <returns>指定属性值的子属性值</returns>
		List<PropertyValue> GetChildPropertyValues(PropertyValue propertyValue);

		/// <summary>
		/// 获取指定属性的父辈属性值
		/// </summary>
		/// <param name="propertyValue">子属性对象</param>
		/// <returns>指定子属性的父辈属性对象</returns>
		PropertyValue GetParentPropertyValue(PropertyValue propertyValue);

		#endregion
	}
}